﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DBExperment
{
    public partial class BorrowRecord : UserControl
    {
        public int tid=123213;
        public DataTable RecordList;
        private List<Record> Records = new List<Record>();
        public BorrowRecord()
        {
            InitializeComponent();
            FillBookTable();
        }

        public void FillBookTable()
        {

            RecordList = new DataTable();
            RecordList.Columns.Add("书名");
            RecordList.Columns.Add("学校");
            RecordList.Columns.Add("图书馆");
            RecordList.Columns.Add("借书时间");

            {
                string sql = @"SELECT BookID,Date From tb_LibraryCard where TID=" + tid;
                //MessageBox.Show(sql);
                Records = DBExperment.Data.FindRecord(sql);

            }

            object[] values = new object[4];

            for (int i = 0; i < Records.Count; i++)
            {
                values[0] = Records[i].BName;
                values[1] = Records[i].School;
                values[2] = Records[i].Liberty;
                values[3] = Records[i].Date;
                RecordList.Rows.Add(values);
            }



            DGV_Borrow.DataSource = RecordList;
            DGV_Borrow.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            DGV_Borrow.Columns[0].FillWeight = 20;
            DGV_Borrow.Columns[1].FillWeight = 20;
            DGV_Borrow.Columns[2].FillWeight = 20;
            DGV_Borrow.Columns[3].FillWeight = 20;
        }

        private void kryptonButton1_Click(object sender, EventArgs e)
        {
            FillBookTable();
        }


    }
}
